package com.codebo.homiematch.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.codebo.homiematch.common.BaseResponse;
import com.codebo.homiematch.common.ResultUtils;
import com.codebo.homiematch.model.dto.LoveRequest;
import com.codebo.homiematch.model.dto.UserListQueryRequest;
import com.codebo.homiematch.model.vo.UserVO;
import com.codebo.homiematch.service.HomeService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/home")
public class HomeController
{
    @Resource
    private HomeService homeService;

    @PostMapping("/userList")
    public BaseResponse<Page<UserVO>> userList(@RequestBody UserListQueryRequest userListQueryRequest)
    {
        Page<UserVO> userVOList = homeService.getUserList(userListQueryRequest);

        return ResultUtils.success(userVOList);
    }

    @PostMapping("/love")
    public BaseResponse<List<UserVO>> love(@RequestBody LoveRequest loveRequest)
    {
        System.out.println("loveRequest = " + loveRequest);
        List<UserVO> love = homeService.love(loveRequest);
        return ResultUtils.success(love);
    }
}
